<template>
    <div class="product-list-item fl" @click="onClick">
        <div class="img-box">
            <img mode="aspectFill" :src="cover" alt="">
            <!-- <div v-if="tag" class="label white-color primary-bg text-tiny">{{tag}}</div> -->
        </div>
        <div class="info-box">
            <div class="title-box normal-text font-bold hidden-text-v2">
                {{name}}
            </div>
            <div class="tag-box white-color" v-if="showTag">
                <!-- <div class="tag yellow-bg">呵呵呵</div> -->
                <!-- <div class="tag blue-bg">做个人吧</div> -->
                <div class="tag yellow-bg" v-if="tag">{{tag}}</div>
                <div class="tag blue-bg" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{shopName ? shopName : '品质联盟甄选商家'}}</div>
            </div>
            <div class="feature-box text-tiny">
                <div class="price-box">
                    <div class="product-list-item__price">
                        <span class="color-red text-large">¥{{price | currency}}</span>
                        <span v-if="displayPrice" class="product-list-item__display-price">原价{{displayPrice | currency}}</span>
                    </div>
                    <!-- <div v-if="shopTag" class="label text-tiny orange-gold-color">
                        <img class="medal" src="https://static.playground.forzoom.tech/meta/zhuyintiancheng/shop/shop_medal.png" />
                        <span class="tag">{{shopTag}}</span>
                    </div> -->
                </div>
                <div class="feature text-tiny">
                    <div class="view">阅读量 {{readNumber}}</div>
                    <div class="share">分享 {{shareNumber}}</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts">
import {
    currency,
} from '@/lib/utils';

import { Component, Vue, Prop } from 'vue-property-decorator';

@Component({
    name: 'ProductListItem',
})
export default class ProductListItem extends Vue {
    /** 封面 */
    @Prop({ type: String }) public cover?: string;
    /** 名字 */
    @Prop({ type: String }) public name?: string;
    /** 价格 */
    @Prop({ type: [ Number, String ] }) public price: any;
    @Prop({ type: [ Number, String ] }) public displayPrice: any;
    @Prop({ type: Boolean, default: true }) public showTag: any;
    /** 标签 */
    @Prop({ type: String }) public tag: any;
    /** 关键字 */
    @Prop({ type: String }) public keywords: any;
    /** 店铺名称 */
    @Prop({ type: String }) public shopName: any;
    /** 店铺标签 */
    @Prop({ type: String }) public shopTag: any;
    /** 阅读数 */
    @Prop({ type: Number }) public readNumber: any;
    /** 分享数 */
    @Prop({ type: Number }) public shareNumber: any;

    /**
     * 点击
     */
    public onClick() {
        this.$emit('click');
    }
}
</script>

<style lang="less">
@import "../../lib/style/mixins.less";

.product-list-item {
    display: flex;
    flex-direction: column;
    // justify-content: space-around;
    width: 162px;
    height: 281px;
    // padding-bottom: 5px;
    margin-top: 10px;
    margin-right: 13px;
    box-shadow: 0px 7px 14px 0px rgba(248, 234, 234, 0.5);
    border-radius: 4px 4px 8px 8px;
    overflow: hidden;
    box-sizing: border-box;

    .img-box {
        position: relative;
        width: 100%;
        height: 166px;
        // border-radius: 8px 8px 0 0;
        image {
            width: 100%;
            height: 100%;
            // border-radius: 7px 7px 0 0;
        }
        .label {
            position: absolute;
            bottom: -7px;
            left: 10px;
            padding: 2px 8px;
            border-radius: 7px 0 7px;
        }
    }
    .info-box {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        flex: 1;
        padding: 0 10px 5px;
        .title-box {
            max-height: 40px;
        }
        .tag-box {
            display: flex;
            flex-wrap: wrap;
            .tag {
                padding: 0 10px;
                margin-right: 10px;
                line-height: 16px;
                font-size: 8px;
                border-radius: 8px;
            }
        }
        .feature-box {
            // display: flex;
            // justify-content: space-between;
            // align-items: flex-end;
            // margin-top: 5px;
            .feature {
                display: flex;
                justify-content: space-between;
                align-items: center;
                color: rgba(16, 16, 16, 0.57);
                text-align: right;
            }
            .label {
                display: inline-block;
                background-color: @color-gold;
                .medal {
                    width: 11px;
                    height: 11px;
                }
                .tag {
                    padding: 0 10px;
                }
            }
        }
    }

    &__price {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
    }
    &__display-price {
        display: inline-block;
        padding-left: 5px;
        .text-small();
        color: @color-font-4;
        text-decoration: line-through;
    }
}

</style>
